package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallGoodsSpecification;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallGoodsSpecificationMapper {
    @Delete({
        "delete from haogoumall_goods_specification",
        "where goods_specification_id = #{goodsSpecificationId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer goodsSpecificationId);

    @Insert({
        "insert into haogoumall_goods_specification (goods_specification_id, goods_id, ",
        "goods_specification_specification, goods_specification_value, ",
        "goods_specification_pic_url, goods_specification_add_time, ",
        "goods_specification_update_time, goods_specification_deleted)",
        "values (#{goodsSpecificationId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, ",
        "#{goodsSpecificationSpecification,jdbcType=VARCHAR}, #{goodsSpecificationValue,jdbcType=VARCHAR}, ",
        "#{goodsSpecificationPicUrl,jdbcType=VARCHAR}, #{goodsSpecificationAddTime,jdbcType=TIMESTAMP}, ",
        "#{goodsSpecificationUpdateTime,jdbcType=TIMESTAMP}, #{goodsSpecificationDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallGoodsSpecification record);

    @InsertProvider(type=HaogoumallGoodsSpecificationSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallGoodsSpecification record);

    @Select({
        "select",
        "goods_specification_id, goods_id, goods_specification_specification, goods_specification_value, ",
        "goods_specification_pic_url, goods_specification_add_time, goods_specification_update_time, ",
        "goods_specification_deleted",
        "from haogoumall_goods_specification",
        "where goods_specification_id = #{goodsSpecificationId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="goods_specification_id", property="goodsSpecificationId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.INTEGER),
        @Result(column="goods_specification_specification", property="goodsSpecificationSpecification", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_specification_value", property="goodsSpecificationValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_specification_pic_url", property="goodsSpecificationPicUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_specification_add_time", property="goodsSpecificationAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="goods_specification_update_time", property="goodsSpecificationUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="goods_specification_deleted", property="goodsSpecificationDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallGoodsSpecification selectByPrimaryKey(Integer goodsSpecificationId);

    @UpdateProvider(type=HaogoumallGoodsSpecificationSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallGoodsSpecification record);

    @Update({
        "update haogoumall_goods_specification",
        "set goods_id = #{goodsId,jdbcType=INTEGER},",
          "goods_specification_specification = #{goodsSpecificationSpecification,jdbcType=VARCHAR},",
          "goods_specification_value = #{goodsSpecificationValue,jdbcType=VARCHAR},",
          "goods_specification_pic_url = #{goodsSpecificationPicUrl,jdbcType=VARCHAR},",
          "goods_specification_add_time = #{goodsSpecificationAddTime,jdbcType=TIMESTAMP},",
          "goods_specification_update_time = #{goodsSpecificationUpdateTime,jdbcType=TIMESTAMP},",
          "goods_specification_deleted = #{goodsSpecificationDeleted,jdbcType=BIT}",
        "where goods_specification_id = #{goodsSpecificationId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallGoodsSpecification record);
}